package com.woniuxy.controller;

import com.woniuxy.entity.Operation;
import com.woniuxy.entity.PageBean;
import com.woniuxy.entity.ResponseResult;
import com.woniuxy.service.OperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OperationController {
    @Autowired
    OperationService operationService;

    @PostMapping("/operation/{pageIndex}/{pageSize}")
    public ResponseResult getOperations(@PathVariable("pageIndex") int pageIndex, @PathVariable("pageSize") int pageSize,
                                        @RequestBody Operation operation){
        PageBean<Operation> pageBean = operationService.getOperationsByCondition(operation, pageIndex, pageSize);
        System.out.println(pageBean);
        return new ResponseResult(200, "ok", pageBean);
    }

    //通过选择不同科室查询
    @PostMapping("/operationBydepartmentsId/{pageIndex}/{pageSize}")
    public ResponseResult getoperationBydepartmentsId(@PathVariable("pageIndex") int pageIndex, @PathVariable("pageSize") int pageSize,
                                        @RequestBody Operation operation){
        PageBean<Operation> pageBean = operationService.getOperationPageByDepartment(operation, pageIndex, pageSize);

        return new ResponseResult(200, "ok", pageBean);
    }

    //通过选择不同等级查询
    @PostMapping("/operationByOperationGrade/{pageIndex}/{pageSize}")
    public ResponseResult getoperationByOperationGrade(@PathVariable("pageIndex") int pageIndex, @PathVariable("pageSize") int pageSize,
                                        @RequestBody Operation operation){
        PageBean<Operation> pageBean = operationService.getOperationPageByOperationGrade(operation, pageIndex, pageSize);

        return new ResponseResult(200, "ok", pageBean);
    }
}
